feat(my-space): update company info banner to match new design#3168
feat(my-space): update company info banner to match new design#3168LucasCharrier merged 4 commits intoalphafrom
Conversation
revu-bot
left a comment
There was a problem hiding this comment.
Summary
This PR updates the CompanyInfoBanner component to match a new design: flatter layout using flexbox rows, a new formatAddress utility for title-casing INSEE/Weez uppercase addresses, and minor copy/style tweaks. The overall approach is clean and well-tested.
| File | Lines | Severity | Issue |
|---|---|---|---|
formatAddress.ts |
20–24 | CRITICAL | offset parameter is the byte offset of the match, not the word index — first-word detection is broken for addresses starting with digits or punctuation |
formatAddress.ts |
19–24 | IMPORTANT | No JSDoc on exported public function (violates coding guidelines) |
formatAddress.ts |
1–24 | IMPORTANT | Missing dedicated unit tests for formatAddress edge cases |
One critical logic bug in formatAddress needs fixing before merge; the other two are important maintainability gaps.
| export function formatAddress(address: string): string { | ||
| return address | ||
| .toLocaleLowerCase("fr-FR") | ||
| .replace(/\p{L}+/gu, (word, offset: number) => { | ||
| if (offset > 0 && LOWERCASE_WORDS.has(word)) return word; | ||
| return word[0]!.toLocaleUpperCase("fr-FR") + word.slice(1); | ||
| }); | ||
| } |
There was a problem hiding this comment.
[CRITICAL] offset is the character offset of the match, not the word index — first-word capitalisation is broken
Why it matters:
- The
offsetparameter passed byString.prototype.replaceis the character position of the match within the string, not a word counter. offset > 0is thereforefalseonly when the very first character of the entire string is a letter. Any address that starts with a digit or whitespace (e.g."12 RUE DE PARIS") will haveoffset > 0for every word, including"rue", which is inLOWERCASE_WORDS— so"rue"will be left lowercase instead of being capitalised.- Concretely,
formatAddress("12 RUE DE PARIS")currently returns"12 rue de paris"instead of"12 Rue de Paris".
Proposed fix: track whether a capitalised word has already been emitted using a closure variable.
| export function formatAddress(address: string): string { | |
| return address | |
| .toLocaleLowerCase("fr-FR") | |
| .replace(/\p{L}+/gu, (word, offset: number) => { | |
| if (offset > 0 && LOWERCASE_WORDS.has(word)) return word; | |
| return word[0]!.toLocaleUpperCase("fr-FR") + word.slice(1); | |
| }); | |
| } | |
| export function formatAddress(address: string): string { | |
| let firstWordCapitalised = false; | |
| return address | |
| .toLocaleLowerCase("fr-FR") | |
| .replace(/\p{L}+/gu, (word) => { | |
| if (firstWordCapitalised && LOWERCASE_WORDS.has(word)) return word; | |
| firstWordCapitalised = true; | |
| return word[0]!.toLocaleUpperCase("fr-FR") + word.slice(1); | |
| }); | |
| } |
This correctly capitalises the first alphabetic word regardless of any leading digits/punctuation, and keeps connector words lowercase thereafter.
There was a problem hiding this comment.
False positive: rue is not in LOWERCASE_WORDS (only connectors like de, du, la, le, les, et, en, aux, sur, sous, d, l). The existing test "12 RUE DE PARIS, 75001 PARIS" → "12 Rue de Paris, 75001 Paris" passes. The offset > 0 guard exists to capitalize a connector when it's the very first word (e.g. "LE MANS" → "Le Mans").
| "l", | ||
| ]); | ||
|
|
||
| export function formatAddress(address: string): string { |
There was a problem hiding this comment.
[IMPORTANT] Missing JSDoc on exported public function
Why it matters:
- The coding guidelines require public functions to have concise docstrings explaining purpose and return values.
formatAddressis exported and non-trivial (locale-aware title-casing with a connector-word allowlist), so future readers benefit from a brief description.
Proposed addition:
| export function formatAddress(address: string): string { | |
| /** | |
| * Converts a fully-uppercased INSEE/Weez address to title case. | |
| * Short French connector words (de, du, la, le, …) are kept lowercase | |
| * unless they are the first word of the address. | |
| * | |
| * @param address - The raw uppercase address string. | |
| * @returns The address formatted in title case. | |
| */ | |
| export function formatAddress(address: string): string { |
|
🎉 Deployment for commit 0112bcb : Docker images
|
No description provided.